package com.enfi.api.modules.db.base;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;
import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.http.HttpMethod;

import java.util.Collection;

/**
 * @author wind
 * @since 2020-04-07 15:47:33
 */
@NoRepositoryBean
public interface BaseService<R extends JpaRepositoryImplementation<T,ID>,T,ID> extends JpaRepositoryImplementation<T, ID> {
   
       /**
     * class
     * @return
     */
    public Class<T> getEntityClass();
     /**
     * 设置仓库
     * @param r
     * @return
     */
    public  void setRepository(R r);

    /**
     * 查询
     * @param t
     * @param pageable
     * @return
     */
    public Page find(MatchQuery query, T t, Pageable pageable);

    /**
     * 查询
     * @param query
     * @return
     */
    public Page find(BaseQuery query,T t);

    /**
     *  更新
     * @param t
     * @return
     */
    public boolean update(T t,HttpMethod httpMethod);


    /**
     *  批量更新
     * @param t
     * @return
     */
    public boolean update(Collection<T> collection,HttpMethod httpMethod);

    /**
     *  保存
     * @param t
     * @return
     */
    public boolean insert(T t);

    /**
     *  保存
     * @param t
     * @return
     */
    public boolean insertAll(Collection<T> collection);
    /**
     * 删除
     * @param t
     * @return
     */
    public boolean remove(T t);
}